package com.example.month11.listview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

import com.example.month11.listview.lv.ChatAdapter;
import com.example.month11.listview.lv.ChatMessage;
import com.example.recyclerview01.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ListView mListView;
    private List<String> mDatas = new ArrayList<String>(Arrays.asList("Hello",
            "World", "Welcome"));
//    private MyAdapter mAdapter;
    private CommonAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        mListView = (ListView) findViewById(R.id.id_lv_main);
//        mListView.setAdapter(mAdapter = new MyAdapter(this, mDatas));
//        mListView.setAdapter(mAdapter = new CommonAdapter<String>(this, mDatas, R.layout.lv_item) {
//            @Override
//            public void convert(ViewHolder viewHolder, String item) {
////                TextView view = viewHolder.getView(R.id.id_tv_title);
////                view.setText(item);
//                viewHolder.setText(R.id.id_tv_title, item);
//            }
//        });

        // 多布局的使用。
        mListView.setDivider(null);
        mListView.setAdapter(new ChatAdapter(this, ChatMessage.MOCK_DATAS));
    }

}